import cv2
import numpy as np


class Simple_Processor(object):
    def __init__(self, width: int, height: int, inter=cv2.INTER_AREA):
        """
        初始化图片预处理器

        :param width: 自定义重塑后图片宽
        :param height: 自定义重塑后图片高
        :param inter: 插值方法(具体百度)
        """
        self.width = width
        self.height = height
        self.inter = inter

    def processor(self, image: np.ndarray):
        """
        预处理器

        :param image: cv2读取后的图像对象
        :return: cv2重塑后的图片对象（忽略纵横比）
        """
        return cv2.resize(image, (self.width, self.height),
                          interpolation=self.inter)


if __name__ == '__main__':
    s = Simple_Processor(20, 20)
    g = cv2.imread('../dataset/train_pac/cat.0.jpg')
    t = s.processor(g)
    print(t.size)
